package io.zcoder.innoway.activities;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.zcoder.innoway.R;
import io.zcoder.innoway.commons.Constants;

public class TrendListActivity extends BaseActivity {

    public static final int RESULT_INDEX_ENTRY = 89;

    @BindView(R.id.common_close)
    ImageView mClose;
    @BindViews({R.id.entry_1, R.id.entry_2, R.id.entry_3, R.id.entry_4, R.id.entry_6, R.id.entry_7, R.id.entry_8, R.id.entry_9})
    LinearLayout[] mItems;

    @OnClick(R.id.common_close)
    void close() {
        finish();
    }

    @OnClick({R.id.entry_1, R.id.entry_2, R.id.entry_3, R.id.entry_4, R.id.entry_6, R.id.entry_7, R.id.entry_8, R.id.entry_9})
    void selectEntry(View view) {
        for (int i = 0; i < mItems.length; i++) {
            if (view.getId() == mItems[i].getId()) {
                Intent intent = new Intent();
                intent.putExtra(Constants.INDEX_EXTRAS, i);
                setResult(RESULT_INDEX_ENTRY, intent);
                finish();
                break;
            }
        }
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_trend_list_activity);
        ButterKnife.bind(this);
        setTitle(getString(R.string.trends_list));
        mClose.setVisibility(View.VISIBLE);
    }
}
